{extends 'base/site2.html'}
{block name="page_header"}{include file="common/header.html" inline}{/block}
{block name="page_nav"}{include file="common/slide-nav.html" inline}{/block}
{block name="page_styles"}
    <link rel="stylesheet" type="text/css" href="/css/mediation/entryrepay/index.css" />

{/block}

{block name="page_section"}


    <div class="sessionPage bg-fff">
        <input type="hidden" id="delete_id" value="">
        <div class="page-header">
          <div class="left">
            <span class="line"></span>
            <strong class="tit">还款记录</strong>
          </div>
        </div>
        <form method="get" action=""  id="form-ele" class="clearfix small-style" role="validform" enctype="multipart/form-data">
          <div class="form_row">
            <input type="hidden" name="limit" value="{if $query.limit}{$query.limit}{/if}">
            <div class="form-group col-lg-3 ui-select">
                <label for="exampleInputName2"  class="col-sm-4 control-label">调解部门:</label>
                <div class="col-sm-7">
                    <select class="form-control selectpicker"   title="请选择" name="mediationOrganId" id="mediationOrganId">
                        {foreach from=$mediationOrgan item=info}
                            <option class="u144_input_option" {if $info.id==$query.mediationOrganId}selected="selected"{/if} value="{$info.id}">{$info.name}</option>
                        {/foreach}
                    </select>
                </div>
            </div>
              <div class="form-group col-lg-3 ui-select">
                  <label for="exampleInputName2"  class="col-sm-4 control-label">调解员:</label>
                  <div class="col-sm-7">
                      <select class="form-control" id="is_contrast" name="mediatorId">
                          <option class="u144_input_option" {if $query.mediatorId==0}selected="selected"{/if} value="0">全部</option>
                          {foreach from=$mediator item=item }
                          {if $item.id != 1}
                          <option class="u144_input_option" {if $query.mediatorId == $item.id}selected="selected"{/if} value="{$item.id}">{$item.name}</option>
                          {/if}
                          {/foreach}
                      </select>
                  </div>
              </div>
            <div class="form-group col-lg-3 ui-select">
                <label for="exampleInputName2"  class="col-sm-4 control-label">当事人:</label>
                <div class="col-sm-7">
                    <input type="text" class="form-control noempty col-sm-4"  value="{if !empty($query.litigantName)}{$query.litigantName}{/if}" name="litigantName" id="litigantName" placeholder="请输入~">
                </div>
            </div>
            <div class="form-group col-lg-3 ui-select">
                <label for="exampleInputName2"  class="col-sm-4 control-label">案件号:</label>
                <div class="col-sm-7">
                    <input type="text" class="form-control noempty col-sm-4"  value="{if !empty($query.caseId)}{$query.caseId}{/if}" name="caseId" id="caseId" placeholder="请输入~">
                </div>
            </div>

          </div>
            <div class="form_row">
                <div class="form-group col-lg-3 ui-select">
                    <label for="exampleInputName2"  class="col-sm-4 control-label">资产方:</label>
                    <div class="col-sm-7">
                        <select class="form-control selectpicker"   title="请选择" name="assetsId" id="assetsId">
                            {foreach from=$assets  item=info}
                            <option class="u144_input_option" {if !empty($query.assetsId) &&  $info.id == $query.assetsId}selected="selected"{/if} value="{$info.id}">{$info.name}</option>
                            {/foreach}
                        </select>
                    </div>
                </div>
                <div class="form-group col-lg-3 ui-select">
                    <label class="col-sm-4 control-label">
                        还款时间:
                    </label>
                    <div class="col-sm-7">
                        <input data-ele="date" data-type="daterange" name="realRepaymentDate_begin_end" class="form-control" placeholder="请选择" value="{if !empty($smarty.get.realRepaymentDate_begin_end)}{$smarty.get.realRepaymentDate_begin_end}{/if}" autocomplete="off"/>
                    </div>

                </div>
                <div class="form-group col-lg-3 ui-select">
                    <label class="col-sm-4 control-label">
                        添加时间:
                    </label>
                    <div class="col-sm-7">
                        <input data-ele="date" data-type="daterange" name="addDate_begin_end" class="form-control" placeholder="请选择" value="{if !empty($smarty.get.addDate_begin_end)}{$smarty.get.addDate_begin_end}{/if}" autocomplete="off"/>
                    </div>

                </div>
                <div class="form-group col-lg-3 ui-select">
                    <div class="col-lg-5">
                        <button class="btn btn-primary col-lg-8 shousuoBtn"><span class="nav-icon glyphicon glyphicon-search" aria-hidden="true" style="margin-right: 2px"></span>查询</button>
                    </div>
                    <div class="col-lg-5">
                        <a type="button" href="/returnedmoneyplan/history" class="btn btn-default col-lg-8" ><span class="nav-icon glyphicon glyphicon-refresh" aria-hidden="true" style="margin-right: 2px"></span>重置</a>
                    </div>
                    <div class="col-lg-5" style="float: right;">
                        <button  class="btn btn-info col-lg-8 data_upload"><span class="nav-icon glyphicon glyphicon-download-alt" aria-hidden="true" style="margin-right: 2px"></span>导出</button>
                    </div>
                </div>
            </div>

<!--            <div class="form_row">-->
<!--           -->
<!--            <div class="ui-select"></div>-->
<!--            <div class="ui-select"></div>-->
<!--            <div class="ui-select"></div>-->
<!--          </div>-->

        </form >
        <div style="width: 95%;
        margin: 0 auto;
        display: flex;
        flex-direction: column;
        overflow-x: scroll;">
            <table class="table table-striped table-bordered table-hover text-nowrap">
            <thead>
            <tr>
                <th scope="col">调解组</th>
                <th scope="col">资产方</th>
                <th scope="col">调解号</th>
                <th scope="col">案件标识号</th>
                <th scope="col">当事人</th>
                <th scope="col">添加人</th>
                <th scope="col">审核状态</th>
                <th scope="col">预计还款金额</th>
                <th scope="col">实际还款金额</th>
                <th scope="col">预计还款日期</th>
                <th scope="col">实际还款日期</th>
                <th scope="col">添加时间</th>
                <th scope="col">逾期期数M</th>
                <th scope="col">还款备注</th>
                <th scope="col" class="fix-ele">操作</th>
            </tr>
            </thead>

            <tbody>
            {if $list}
                {foreach from=$list item=info key=key name=a}
                    <tr>
                        <td>{$mediationOrgan[$info['mediationOrganId']]['name']}</td>
                        <td>{$assets[$info['assetsId']]['name']}</td>
                        <td>{$info['mediationNum']}</td>
                        <td>{$info['batshId']}</td>
                        <td>{$info['litigantName']}</td>
                        <td>{$info['mediatorName']}</td>
                        <td>{$planStatusArr[$info['status']]}</td>
                        <td>{$info['repayAmount']}</td>
                        <td>{$info['realRepayAmount']}</td>
                        <td>{if !empty($info['repaymentDate'])}{$info['repaymentDate']|date_format:"%Y/%m/%d"}{/if}</td>
                        <td>{if !empty($info['realRepaymentDate'])}{$info['realRepaymentDate']|date_format:"%Y/%m/%d"}{/if}</td>
                        <td>{if !empty($info['addTime'])}{$info['addTime']|date_format:"%Y/%m/%d"}{/if}</td>
                        <td>M{$info['overdueMonth']}</td>
                        <td>{$info['notes']}</td>

                        <td class="fix-ele">

                        <a href="../{$info.filepath}" target="_blank" class='withdraw_one' >查阅凭证</a>

                        </td>
                    </tr>
                {/foreach}
            {/if}
            </tbody>
        </table>
        </div>
        <div class="clearfix pad-no text-nowrap" style="margin-top: 20px;">
            {include file="base/pagenav.html"  action="/returnedmoneyplan/history" pagenum=$curPageNum inline}
            <select class="form-control" id="paglimit" style="float:right;margin:0 10px;width: auto;margin-top: -5px;">
                <option value="limit=10" {if $query.limit==10}selected="selected"{/if}>10条/页</option>
                <option value="limit=20" {if $query.limit==20}selected="selected"{/if}>20条/页</option>
                <option value="limit=50" {if $query.limit==50}selected="selected"{/if}>50条/页</option>
                <option value="limit=100" {if $query.limit==100}selected="selected"{/if}>100条/页</option>
            </select>
            <span style="float:right;">总还款 {number_format($totalAmount,2)} 元 , 共 {$totalnum} 条</span>
        </div>
    </div>




{/block}
{block name="page_scripts"}
<script type="text/javascript">


    $(".data_upload").on("click",function(){
        var is_down =confirm('请确认是否下载？\n'+ '下载时间可能比较慢,点击后请耐心等待!') ;
        if(is_down){
            $("#form-ele").attr('action','/returnedmoneyplan/historyexport');
            $("#form-ele").submit();

        }
    });

    $(".shousuoBtn").on("click",function(){
            $("#form-ele").attr('action','');
            $("#form-ele").submit();

    });
    function GetQueryString(name){
        var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if(r!=null)return  unescape(r[2]); return null;
    }
    $('body').on('change','#paglimit', function(){
        console.log()
        var mediationOrganId = GetQueryString('mediationOrganId');
        var paglimit = GetQueryString('limit');
        var val =  $(this).val();
        if(!mediationOrganId){
            if(!paglimit){
                window.location = window.location.href+'?'+val;
            } else{
                window.location = window.location.href.replace('limit='+paglimit,val);
            }
        }else{
            if(!paglimit){
                window.location = window.location.href+'&'+val;
            } else{
                window.location = window.location.href.replace('limit='+paglimit,val);
            }
        }
    })


    </script>
{/block}
